/*
 * @Description:
 * @Author: young (young2f@outlook.com)
 * @Date: 2019-09-11 13:30:59
 * @LastEditTime : 2020-01-29 00:06:00
 */
/**
 * create by young (young2f@outlook.com) on 2019/1/13
 */
'use strict';
const path = require('path');

module.exports = appInfo => {
    const config = {};

    /**
     * 文件路径
     * @type {string}
     */
    config.rootPath = path.resolve(__dirname, '../../');
    config.logsPath = path.resolve(__dirname, '../../aiProdLogs');
    config.infoPath = path.resolve(__dirname, '../info');
    config.configInfoPath = config.infoPath + '/config';
    config.sysConfigFile = config.infoPath + '/iiot-config.json';
    config.logger = {
        dir: config.logsPath,
        level: 'INFO',
        outputJSON: true

    };
//2 * 1024 * 1024 * 1024
    config.customLogger = {
        scheduleLogger: {
            consoleLevel: 'NONE',
            file: config.logsPath + '/egg-schedule.log',
        },
    };


    // config.schedule = {
    //   directory: [],
    // };

    /**
     * mongo
     */
    const mongoUrl = '127.0.0.1:22900';
    // const mongoUrl = '119.45.189.48:22900';
    const businessUser = 'aiotBusiness';
    const businessUserPs = 'Afei!168';


    const businessUrl = `mongodb://${businessUser}:${businessUserPs}@${mongoUrl}/${businessUser}`;


    config.mongoose = {
        clients: {
            aiotBusiness: {
                url: businessUrl,
                options: {
                    // useNewUrlParser: true,
                    useUnifiedTopology: true,
                    // autoReconnect: true,
                    //   reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
                    // reconnectInterval: 500, // Reconnect every 500ms
                    //  useFindAndModify: false
                },
            }
        }
    };
// config/config.${env}.js
    config.mysql = {
        client: {
            host: '127.0.0.1',
            port: '3306',
            user: 'root',
            password: 'admin123',
            database: 'iot'
        },
        app: true,  // 是否挂载到 app 对象
        agent: false // 是否挂载到 agent 对象
    };
    config.iiotConfig = {
        logger: {
            'level': 'WARN'
        },
        mqtt: {
            enable: true,
            // url: 'tcp://www.iotmqtt.cn',
            // port: 21883,
            url: 'tcp://60.173.17.240',
            port: 10049,
            // url: 'tcp://127.0.0.1',
            // url: 'tcp://10.13.60.134',
            // port: 1883,
            usr: 'mqtt',
            pwd: 'ztesoft'
        },
        rootPath: '/opt',
        defaultDeviceOnlineSpaceTime: 30
    };
    return config;
};
